﻿/*
 *   StringFunctionsTests.cs
 *   Copyright (c) 2011 - BitFox Software and Ricardo Federico Villafañes
 *   Contact: federvillaf@hotmail.com
 *   
 *   Licensing: This product is covered by Microsoft Reciprocal License (MS-RL)
 *              see https://bitfoxeval.codeplex.com/license
*/

using System;
using System.Globalization;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using BitFox.Evaluator;

namespace TestEvaluator
{
    /// <summary>
    /// Tests related, mainly, to string functions
    /// </summary>
    [TestClass]
    public class StringFunctionsTests
    {
        // The evaluator to use in tests
        Evaluator eval = new Evaluator();

        /// <summary>
        /// Empty constructor
        /// </summary>
        public StringFunctionsTests()
        {
        }

        /// <summary>
        /// The context under which tests are runned.
        ///</summary>
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void TestLTrim()
        {
            Assert.AreEqual("hola", (string)eval.Compile("ltrim('  hola')").Run());
            Assert.AreEqual("hola   ", (string)eval.Compile("ltrim('  hola   ')").Run());
            Assert.AreEqual("hola   ", (string)eval.Compile("ltrim('hola   ')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("ltrim('hola')").Run());
            Assert.AreEqual("", (string)eval.Compile("ltrim('  ')").Run());
            Assert.AreEqual("", (string)eval.Compile("ltrim('')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("ltri('hola')").Run());
        }

        [TestMethod]
        public void TestRTrim()
        {
            Assert.AreEqual("  hola", (string)eval.Compile("rtrim('  hola')").Run());
            Assert.AreEqual("  hola", (string)eval.Compile("rtrim('  hola   ')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("rtrim('hola   ')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("rtrim('hola')").Run());
            Assert.AreEqual("", (string)eval.Compile("rtrim('  ')").Run());
            Assert.AreEqual("", (string)eval.Compile("rtrim('')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("rtri('hola')").Run());
        }

        [TestMethod]
        public void TestAlltrim()
        {
            Assert.AreEqual("hola", (string)eval.Compile("alltrim('  hola  ')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("alltrim('hola  ')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("alltrim('  hola')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("alltrim('hola')").Run());
            Assert.AreEqual("", (string)eval.Compile("alltrim('  ')").Run());
            Assert.AreEqual("", (string)eval.Compile("alltrim('')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("alltri('hola')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("alltr('hola')").Run());
            Assert.AreEqual("hola", (string)eval.Compile("allt('hola')").Run());
        }

        [TestMethod]
        public void TestLeft()
        {
            Assert.AreEqual("hol", (string)eval.Compile("left('hola', 3)").Run());
            Assert.AreEqual("hola", (string)eval.Compile("left('hola', 4)").Run());
            Assert.AreEqual("hola", (string)eval.Compile("left('hola', 5)").Run());
            Assert.AreEqual("", (string)eval.Compile("left('hola', -1)").Run());
            Assert.AreEqual("", (string)eval.Compile("left('hola', 0)").Run());
            Assert.AreEqual("", (string)eval.Compile("left('', 0)").Run());
            Assert.AreEqual("", (string)eval.Compile("left('', 1)").Run());
        }

        [TestMethod]
        public void TestRight()
        {
            Assert.AreEqual("ola", (string)eval.Compile("right('hola', 3)").Run());
            Assert.AreEqual("hola", (string)eval.Compile("right('hola', 4)").Run());
            Assert.AreEqual("hola", (string)eval.Compile("right('hola', 5)").Run());
            Assert.AreEqual("", (string)eval.Compile("right('hola', -1)").Run());
            Assert.AreEqual("", (string)eval.Compile("right('hola', 0)").Run());
            Assert.AreEqual("", (string)eval.Compile("right('', 0)").Run());
            Assert.AreEqual("", (string)eval.Compile("right('', 1)").Run());
            Assert.AreEqual("hola", (string)eval.Compile("righ('hola', 5)").Run());
        }

        [TestMethod]
        public void TestAsc()
        {
            Assert.AreEqual(0, (int)eval.Compile("asc('')").Run());
            Assert.AreEqual(97, (int)eval.Compile("asc('a')").Run());
            Assert.AreEqual(97, (int)eval.Compile("asc('abcd')").Run());
        }

        [TestMethod]
        public void TestAt()
        {
            Assert.AreEqual(2, (int)eval.Compile("at('ol', 'holahola', 1)").Run());
            Assert.AreEqual(6, (int)eval.Compile("at('ol', 'holahola', 2)").Run());
            Assert.AreEqual(0, (int)eval.Compile("at('ol', 'holahola', 3)").Run());
            Assert.AreEqual(0, (int)eval.Compile("at('ox', 'holahola', 1)").Run());
            Assert.AreEqual(0, (int)eval.Compile("at('', '', 1)").Run());
            Assert.AreEqual(2, (int)eval.Compile("at('ol', 'holahola')").Run());
        }

        [TestMethod]
        public void TestAtC()
        {
            Assert.AreEqual(2, (int)eval.Compile("atc('oL', 'holaHOLA', 1)").Run());
            Assert.AreEqual(6, (int)eval.Compile("atc('oL', 'holaHOLA', 2)").Run());
            Assert.AreEqual(0, (int)eval.Compile("atc('Ol', 'holaHOLA', 3)").Run());
            Assert.AreEqual(0, (int)eval.Compile("atc('oX', 'holaHOLA', 1)").Run());
            Assert.AreEqual(0, (int)eval.Compile("atc('', '', 1)").Run());
            Assert.AreEqual(2, (int)eval.Compile("atc('oL', 'holaHOLA')").Run());
        }

        [TestMethod]
        public void TestBetween()
        {
            // For strings
            Assert.IsTrue((bool)eval.Compile("between('ac', 'ab', 'ad')").Run());
            Assert.IsTrue((bool)eval.Compile("between('ab', 'ab', 'ad')").Run());
            Assert.IsTrue((bool)eval.Compile("between('ad', 'ab', 'ad')").Run());
            Assert.IsFalse((bool)eval.Compile("between('aa', 'ab', 'ad')").Run());
            Assert.IsFalse((bool)eval.Compile("between('ae', 'ab', 'ad')").Run());

            // For dates
            Assert.IsTrue((bool)eval.Compile("between( {^2009/08/03}, {^2009/08/02}, {^2009/08/04})").Run());
            Assert.IsTrue((bool)eval.Compile("between( {^2009/08/02}, {^2009/08/02}, {^2009/08/04})").Run());
            Assert.IsTrue((bool)eval.Compile("between( {^2009/08/04}, {^2009/08/02}, {^2009/08/04})").Run());
            Assert.IsFalse((bool)eval.Compile("between( {^2009/08/05}, {^2009/08/02}, {^2009/08/04})").Run());
            Assert.IsFalse((bool)eval.Compile("between( {^2009/08/05}, {^2009/08/02}, {^2009/08/04})").Run());

            // For numbers
            Assert.IsTrue((bool)eval.Compile("between(7, 6.1, 8.4)").Run());
            Assert.IsTrue((bool)eval.Compile("between(6.1, 6.1, 8.4)").Run());
            Assert.IsTrue((bool)eval.Compile("between(8.4, 6.1, 8.4)").Run());
            Assert.IsFalse((bool)eval.Compile("between(6, 6.1, 8.4)").Run());
            Assert.IsFalse((bool)eval.Compile("between(8.5, 6.1, 8.4)").Run());
        }

        [TestMethod]
        public void TestChr()
        {
            Assert.AreEqual("A", (string)eval.Compile("chr(65)").Run());
        }

        [TestMethod]
        public void TestEmpty()
        {
            // For strings
            Assert.IsTrue((bool)eval.Compile("empty('')").Run());
            Assert.IsTrue((bool)eval.Compile("empty('   ')").Run());
            Assert.IsTrue((bool)eval.Compile("empty(chr(13))").Run());
            Assert.IsTrue((bool)eval.Compile("empty(chr(10))").Run());
            Assert.IsTrue((bool)eval.Compile("empty(chr(9))").Run());
            Assert.IsTrue((bool)eval.Compile("empty('   ' + chr(13) + chr(10) + chr(9))").Run());
            Assert.IsFalse((bool)eval.Compile("empty(' a ')").Run());

            // For numbers
            Assert.IsTrue((bool)eval.Compile("empty(0)").Run());
            Assert.IsTrue((bool)eval.Compile("empty(0.0)").Run());
            Assert.IsFalse((bool)eval.Compile("empty(1)").Run());

            // For dates
            Assert.IsTrue((bool)eval.Compile("empty({})").Run());
            Assert.IsTrue((bool)eval.Compile("empty({  /  /  })").Run());
            Assert.IsFalse((bool)eval.Compile("empty({^2009/07/01})").Run());
        }

        [TestMethod]
        public void TestInList()
        {
            Assert.IsTrue((bool)eval.Compile("inlist(24,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24)").Run());
            Assert.IsTrue((bool)eval.Compile("inlist(1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24)").Run());
            Assert.IsTrue((bool)eval.Compile("inlist(14,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24)").Run());
            Assert.IsFalse((bool)eval.Compile("inlist(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24)").Run());

            Assert.IsTrue((bool)eval.Compile("inlist('lazy', 'what', 'a', 'lazy', 'dog')").Run());
            Assert.IsFalse((bool)eval.Compile("inlist('smart', 'what', 'a', 'lazy', 'dog')").Run());

            Assert.IsTrue((bool)eval.Compile("inlist(.t., .t., .f.)").Run());
            Assert.IsFalse((bool)eval.Compile("inlist(.f., .t., .t.)").Run());

            Assert.IsTrue((bool)eval.Compile("inlist({^2009/10/11}, {^2009/10/11})").Run());
            Assert.IsFalse((bool)eval.Compile("inlist({^2008/10/11}, {^2009/10/11})").Run());
        }

        [TestMethod]
        public void TestIsXXX()
        {
            // isalpha
            Assert.IsTrue((bool)eval.Compile("isalpha('a')").Run());
            Assert.IsTrue((bool)eval.Compile("isalpha('a98s')").Run());
            Assert.IsTrue((bool)eval.Compile("isalpha('A__')").Run());
            Assert.IsFalse((bool)eval.Compile("isalpha('98s')").Run());
            Assert.IsFalse((bool)eval.Compile("isalpha('__')").Run());
            Assert.IsFalse((bool)eval.Compile("isalpha('')").Run());

            // isblank
            Assert.IsTrue((bool)eval.Compile("isblank('')").Run());
            Assert.IsTrue((bool)eval.Compile("isblank('  ')").Run());
            Assert.IsTrue((bool)eval.Compile("isblank({})").Run());
            Assert.IsFalse((bool)eval.Compile("isblank('a')").Run());
            Assert.IsFalse((bool)eval.Compile("isblank(0)").Run());
            Assert.IsFalse((bool)eval.Compile("isblank('{^2009/01/01}')").Run());

            // isdigit
            Assert.IsTrue((bool)eval.Compile("isdigit('0a')").Run());
            Assert.IsFalse((bool)eval.Compile("isdigit('.')").Run());
            Assert.IsFalse((bool)eval.Compile("isdigit('a')").Run());
            Assert.IsFalse((bool)eval.Compile("isdigit('')").Run());

            // islower
            Assert.IsTrue((bool)eval.Compile("islower('aA')").Run());
            Assert.IsTrue((bool)eval.Compile("islower('z9')").Run());
            Assert.IsFalse((bool)eval.Compile("islower('')").Run());
            Assert.IsFalse((bool)eval.Compile("islower('B')").Run());
            Assert.IsFalse((bool)eval.Compile("islower('9')").Run());
            Assert.IsFalse((bool)eval.Compile("islower('_')").Run());

            // isupper
            Assert.IsTrue((bool)eval.Compile("isupper('Aa')").Run());
            Assert.IsTrue((bool)eval.Compile("isupper('Z9')").Run());
            Assert.IsFalse((bool)eval.Compile("isupper('')").Run());
            Assert.IsFalse((bool)eval.Compile("isupper('b')").Run());
            Assert.IsFalse((bool)eval.Compile("isupper('9')").Run());
            Assert.IsFalse((bool)eval.Compile("isupper('_')").Run());
        }

        [TestMethod]
        public void TestLen()
        {
            Assert.AreEqual(5, (int)eval.Compile("len('hello')").Run());
            Assert.AreEqual(1, (int)eval.Compile("len(' ')").Run());
            Assert.AreEqual(0, (int)eval.Compile("len('')").Run());
        }

        [TestMethod]
        public void TestLike()
        {
            Assert.IsTrue((bool)eval.Compile("like('', '')").Run());
            Assert.IsTrue((bool)eval.Compile("like('*', '')").Run());
            Assert.IsTrue((bool)eval.Compile("like('ab', 'ab')").Run());
            Assert.IsTrue((bool)eval.Compile("like('ab*', 'absolute')").Run());
            Assert.IsTrue((bool)eval.Compile("like('ab?olute', 'absolute')").Run());
            Assert.IsTrue((bool)eval.Compile("like('ab?', 'abs')").Run());
            Assert.IsTrue((bool)eval.Compile("like('ab*father', 'absolutefather')").Run());
            Assert.IsTrue((bool)eval.Compile("like('ab***father', 'absolutefather')").Run());

            Assert.IsFalse((bool)eval.Compile("like('?', '')").Run());
            Assert.IsFalse((bool)eval.Compile("like('ab', 'abs')").Run());
            Assert.IsFalse((bool)eval.Compile("like('ab?', 'absolute')").Run());
            Assert.IsFalse((bool)eval.Compile("like('ab?', 'ab')").Run());
            Assert.IsFalse((bool)eval.Compile("like('ab*father', 'absolute')").Run());

        }

        [TestMethod]
        public void TestUpperLower()
        {
            Assert.AreEqual("A12B34C#.", (string)eval.Compile("upper('a12B34c#.')").Run());
            Assert.AreEqual("a12b34c#.", (string)eval.Compile("lower('a12B34c#.')").Run());
        }

        [TestMethod]
        public void TestOccurs()
        {
            Assert.AreEqual(0, (int)eval.Compile("occurs('', '')").Run());
            Assert.AreEqual(0, (int)eval.Compile("occurs('', 'a')").Run());
            Assert.AreEqual(0, (int)eval.Compile("occurs('a', 'bcdefg')").Run());
            Assert.AreEqual(1, (int)eval.Compile("occurs('bc', 'bcdefg')").Run());
            Assert.AreEqual(1, (int)eval.Compile("occurs('fg', 'bcdefg')").Run());
            Assert.AreEqual(1, (int)eval.Compile("occurs('ef', 'bcdefg')").Run());
            Assert.AreEqual(3, (int)eval.Compile("occurs('ef', 'bcdefgefcaef')").Run());
            Assert.AreEqual(3, (int)eval.Compile("occurs('ef', 'efefef')").Run());
            Assert.AreEqual(3, (int)eval.Compile("occurs('ef', 'bcdefgefcaef')").Run());
            Assert.AreEqual(3, (int)eval.Compile("occurs('ee', 'eeeeee')").Run());
            Assert.AreEqual(6, (int)eval.Compile("occurs('e', 'eeeeee')").Run());
        }

        [TestMethod]
        public void TestPadX()
        {
            // PADL
            Assert.AreEqual("ab", (string)eval.Compile("padl('b', 2, 'a')").Run());
            Assert.AreEqual("aaab", (string)eval.Compile("padl('b', 4, 'a')").Run());
            Assert.AreEqual("bcbc", (string)eval.Compile("padl('bcbc', 4, 'a')").Run());
            Assert.AreEqual("bcbcd", (string)eval.Compile("padl('bcbcd', 4, 'a')").Run());
            Assert.AreEqual("axaxbc", (string)eval.Compile("padl('bc', 6, 'ax')").Run());
            Assert.AreEqual("    bc", (string)eval.Compile("padl('bc', 6)").Run());

            // PADR
            Assert.AreEqual("ba", (string)eval.Compile("padr('b', 2, 'a')").Run());
            Assert.AreEqual("baaa", (string)eval.Compile("padr('b', 4, 'a')").Run());
            Assert.AreEqual("bcbc", (string)eval.Compile("padr('bcbc', 4, 'a')").Run());
            Assert.AreEqual("bcbcd", (string)eval.Compile("padr('bcbcd', 4, 'a')").Run());
            Assert.AreEqual("bcaxax", (string)eval.Compile("padr('bc', 6, 'ax')").Run());
            Assert.AreEqual("bc    ", (string)eval.Compile("padr('bc', 6)").Run());

            // PADC
            Assert.AreEqual("ba", (string)eval.Compile("padc('b', 2, 'a')").Run());
            Assert.AreEqual("abaa", (string)eval.Compile("padc('b', 4, 'a')").Run());
            Assert.AreEqual("bcbc", (string)eval.Compile("padc('bcbc', 4, 'a')").Run());
            Assert.AreEqual("bcbcd", (string)eval.Compile("padc('bcbcd', 4, 'a')").Run());
            Assert.AreEqual("axbcax", (string)eval.Compile("padc('bc', 6, 'ax')").Run());
            Assert.AreEqual("axbcaxa", (string)eval.Compile("padc('bc', 7, 'ax')").Run());
            Assert.AreEqual("  bc  ", (string)eval.Compile("padc('bc', 6)").Run());
        }

        [TestMethod]
        public void TestProper()
        {
            Assert.AreEqual("", (string)eval.Compile("proper('')").Run());
            Assert.AreEqual("Hello", (string)eval.Compile("proper('hello')").Run());
            Assert.AreEqual("Hello", (string)eval.Compile("proper('heLLo')").Run());
            Assert.AreEqual("Hello", (string)eval.Compile("proper('HeLLo')").Run());
            Assert.AreEqual("Hello2everybody", (string)eval.Compile("proper('hello2everybody')").Run());
            Assert.AreEqual("Hello 2 Everybody", (string)eval.Compile("proper('hello 2 everybody')").Run());
        }

        [TestMethod]
        public void TestRat()
        {
            Assert.AreEqual(0, (int)eval.Compile("rat('', '', 1)").Run());
            Assert.AreEqual(0, (int)eval.Compile("rat('f', '', 1)").Run());
            Assert.AreEqual(0, (int)eval.Compile("rat('', 'f', 1)").Run());
            Assert.AreEqual(1, (int)eval.Compile("rat('f', 'f', 1)").Run());
            Assert.AreEqual(0, (int)eval.Compile("rat('f', 'f', 2)").Run());
            Assert.AreEqual(8, (int)eval.Compile("rat('f', 'efabcdef', 1)").Run());
            Assert.AreEqual(2, (int)eval.Compile("rat('f', 'efabcdef', 2)").Run());
            Assert.AreEqual(7, (int)eval.Compile("rat('ef', 'efabcdef', 1)").Run());
            Assert.AreEqual(1, (int)eval.Compile("rat('ef', 'efabcdef', 2)").Run());
        }

        [TestMethod]
        public void TestReplicateSpace()
        {
            // REPLICATE
            Assert.AreEqual("", (string)eval.Compile("replicate('', 2)").Run());
            Assert.AreEqual("", (string)eval.Compile("replicate('hello', 0)").Run());
            Assert.AreEqual("hello", (string)eval.Compile("replicate('hello', 1)").Run());
            Assert.AreEqual("hellohello", (string)eval.Compile("replicate('hello', 2)").Run());

            // SPACE
            Assert.AreEqual("", (string)eval.Compile("space(0)").Run());
            Assert.AreEqual(" ", (string)eval.Compile("space(1)").Run());
            Assert.AreEqual("     ", (string)eval.Compile("space(5)").Run());
            Assert.AreEqual("X     X", (string)eval.Compile("'X' + space(5) + 'X'").Run());
        }

        [TestMethod]
        public void TestStr()
        {
            Assert.AreEqual("12.34", (string)eval.Compile("str(12.344, 5, 2)").Run());
            Assert.AreEqual("12.35", (string)eval.Compile("str(12.346, 5, 2)").Run());
            //Assert.AreEqual("12.35", (string)eval.Compile("str(12.345, 5, 2)").Run());
            Assert.AreEqual("     12.35", (string)eval.Compile("str(12.346, 10, 2)").Run());
            Assert.AreEqual("12.3", (string)eval.Compile("str(12.346, 4, 2)").Run());
            Assert.AreEqual("12.3", (string)eval.Compile("str(12.346, 4, 2)").Run());
            Assert.AreEqual(" 12", (string)eval.Compile("str(12.346, 3, 2)").Run());
            Assert.AreEqual("12", (string)eval.Compile("str(12.346, 2, 2)").Run());
            Assert.AreEqual("**", (string)eval.Compile("str(123.346, 2, 2)").Run());
            Assert.AreEqual("        12", (string)eval.Compile("str(12.346)").Run());
            Assert.AreEqual("    12.000", (string)eval.Compile("str(12, 10, 3)").Run());
        }

        [TestMethod]
        public void TestStuff()
        {
            Assert.AreEqual("12bc", (string)eval.Compile("stuff('abc', 1, 1, '12')").Run());
            Assert.AreEqual("a12c", (string)eval.Compile("stuff('abc', 2, 1, '12')").Run());
            Assert.AreEqual("ab12", (string)eval.Compile("stuff('abc', 3, 1, '12')").Run());
            Assert.AreEqual("12c", (string)eval.Compile("stuff('abc', 1, 2, '12')").Run());
            Assert.AreEqual("a12", (string)eval.Compile("stuff('abc', 2, 2, '12')").Run());
            Assert.AreEqual("ab12", (string)eval.Compile("stuff('abc', 3, 2, '12')").Run());
            Assert.AreEqual("abc12", (string)eval.Compile("stuff('abc', 4, 2, '12')").Run());
            Assert.AreEqual("abc12", (string)eval.Compile("stuff('abc', 5, 2, '12')").Run());
        }

        [TestMethod]
        public void TestSubstring()
        {
            Assert.AreEqual("3456", (string)eval.Compile("substr('123456789', 3, 4)").Run());
            Assert.AreEqual("", (string)eval.Compile("substr('123456789', 0)").Run());
        }

        [TestMethod]
        public void TestChrTran()
        {
            Assert.AreEqual("ab0d1", (string)eval.Compile("chrtran('abcde', 'ce', '01')").Run());
            Assert.AreEqual("ab0d\0", (string)eval.Compile("chrtran('abcde', 'ce', '0')").Run());
        }

        [TestMethod]
        public void TestStrTran()
        {
            Assert.AreEqual("holahcaahola", (string)eval.Compile("strtran('holaholahola', 'ol', 'ca', 2, 1)").Run());
            Assert.AreEqual("holahcaahcaahola", (string)eval.Compile("strtran('holaholaholahola', 'ol', 'ca', 2, 2)").Run());
            Assert.AreEqual("holaholaholahola", (string)eval.Compile("strtran('holaholaholahola', 'ox', 'ca', 2, 2)").Run());
            Assert.AreEqual("hoxxxhoxxxhoxxxhoxxx", (string)eval.Compile("strtran('holaholaholahola', 'la', 'xxx')").Run());
            Assert.AreEqual("xxxolaxxxolaxxxolaxxxola", (string)eval.Compile("strtran('holaholaholahola', 'h', 'xxx')").Run());
            Assert.AreEqual("olaolaolaola", (string)eval.Compile("strtran('holaholaholahola', 'h')").Run());
        }

        [TestMethod]
        public void TestSoundex()
        {
            Assert.AreEqual("S530", (string)eval.Compile("soundex('smith')").Run());
            Assert.AreEqual("S530", (string)eval.Compile("soundex('smyth')").Run());
            Assert.AreEqual("G250", (string)eval.Compile("soundex('gizmo')").Run());
            Assert.AreEqual("G320", (string)eval.Compile("soundex('gates')").Run());
            Assert.AreEqual("%000", (string)eval.Compile("soundex('%%')").Run());
            Assert.AreEqual("S000", (string)eval.Compile("soundex('so')").Run());
        }
    }
}
